<?php

/* *
 * 资讯
 */
namespace Common\Model;
use Think\Model;
class HospitalOrderModel extends BaseModel {

    public function queryForList($page=null, $map=null) {
        $list = $this->alias("ho")
            ->join("left join __ADMIN__ emp on emp.employee_id = ho.employee_id")
            ->join("left join __ADMIN__ ad on ad.employee_id = ho.delivery_id")
            ->join("left join __HOSPITAL_OPERATION__ hop on hop.hospital_operation_id = ho.hospital_operation_id")
            ->join("left join __HOSPITAL__ h on h.hospital_id = hop.hospital_id")
            ->where(getWhereSqlByMap($map))
            ->order("ho.update_time desc")
            ->limit($page->firstRow . ',' . $page->listRows)
            ->field("ho.*, emp.admin_name, ad.admin_name as delivery_name, hop.hospital_operation_name, h.hospital_name")
            ->select();

        return $list;

    }

    public function getListCount($map = null) {

        $count = $this->alias("ho")
//            ->join("left join __PRODUCT__ p on p.product_id = wo.product_id")
//            ->join("left join __CUSTOMER__ cus on cus.customer_id = wo.customer_id")
            ->where(getWhereSqlByMap($map))
            ->count();

        return $count;
    }

}

